﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.IO.IsolatedStorage;
using Microsoft.Phone.Tasks;
using Microsoft.Xna.Framework.Input.Touch;



namespace KOF.Views
{
    public partial class ShoeDetails : PhoneApplicationPage
    {
        int flag = 0;

        public ShoeDetails()
        {


            InitializeComponent();

        }


        List<string> ListItemSource = new List<string>();
        List<Image> imgList = new List<Image>();
        List<Ellipse> lstEclipse = new List<Ellipse>();
        string shoeid;

        KOF.Helpers.ReleaseResult selectedShoe = new KOF.Helpers.ReleaseResult();



        int intSelectedImage = 0;


        // Set Favorite Star image
        private void SetFavorite()
        {
            try
            {
                if (IsolatedStorageSettings.ApplicationSettings.Contains("FavoritesList"))
                {
                    List<KOF.Helpers.ReleaseResult> lstFav = (List<KOF.Helpers.ReleaseResult>)IsolatedStorageSettings.ApplicationSettings["FavoritesList"];

                    var vCheck = (from f in lstFav
                                  where f.id == shoeid
                                  select f).SingleOrDefault();
                    if (vCheck == null)
                    {
                        imgFavorite.Source = new BitmapImage(new Uri("../Images/ic_button_favorite_inactive.png", UriKind.Relative));

                    }
                    else
                    {
                        imgFavorite.Source = new BitmapImage(new Uri("../Images/ic_button_favorite_active.png", UriKind.Relative));
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Save Favorite Status in local application on Start image Click
        private void imgFavorite_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                if (flag == 1)
                {

                }
                else
                {

                    if (IsolatedStorageSettings.ApplicationSettings.Contains("FavoritesList"))
                    {
                        List<KOF.Helpers.ReleaseResult> lstFav = (List<KOF.Helpers.ReleaseResult>)IsolatedStorageSettings.ApplicationSettings["FavoritesList"];

                        var vCheck = (from f in lstFav
                                      where f.id == shoeid
                                      select f).SingleOrDefault();
                        if (vCheck == null)
                        {
                            lstFav.Add(selectedShoe);
                            IsolatedStorageSettings.ApplicationSettings["FavoritesList"] = lstFav;
                            imgFavorite.Source = new BitmapImage(new Uri("../Images/ic_button_favorite_active.png", UriKind.Relative));
                            //calling analytics
                            GoogleAnalytics.EasyTracker.GetTracker().SendView("Favorited: " + selectedShoe.title);
                        }
                        else
                        {
                            lstFav.Remove(vCheck);
                            imgFavorite.Source = new BitmapImage(new Uri("../Images/ic_button_favorite_inactive.png", UriKind.Relative));

                            //calling analytics
                            GoogleAnalytics.EasyTracker.GetTracker().SendView("Unfavorited: " + vCheck.title);
                        }
                        IsolatedStorageSettings.ApplicationSettings["FavoritesList"] = lstFav;
                        IsolatedStorageSettings.ApplicationSettings.Save();
                    }
                    else
                    {
                        List<KOF.Helpers.ReleaseResult> lstFav = new List<Helpers.ReleaseResult>();

                        //calling analytics
                        GoogleAnalytics.EasyTracker.GetTracker().SendView("Favorited: " + selectedShoe.title);
                        lstFav.Add(selectedShoe);
                        IsolatedStorageSettings.ApplicationSettings.Add("FavoritesList", lstFav);
                        IsolatedStorageSettings.ApplicationSettings.Save();
                        imgFavorite.Source = new BitmapImage(new Uri("../Images/ic_button_favorite_active.png", UriKind.Relative));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect to News page  when click on image 
        private void imgKicksOnFire_MouseEnter(object sender, MouseEventArgs e)
        {
            string str = "";
            try
            {
                Image l = (Image)sender;
                if (l.Tag != null)
                {
                    str = l.Tag.ToString();
                }
                this.NavigationService.Navigate(new Uri("/Views/News.xaml?url=" + str + "&id=" + shoeid, UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Go Back
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                IsolatedStorageSettings.ApplicationSettings["loader"] = false;
                this.NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));

                flag = 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Facebook Share Status
        private void imgFacebook_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareLinkTask shareOnFB = new ShareLinkTask();
                shareOnFB.Title = selectedShoe.title;
                string strMsg = !String.IsNullOrWhiteSpace(selectedShoe.kof_link) ? ("-" + Environment.NewLine + selectedShoe.kof_link) : string.Empty;
                shareOnFB.Message = selectedShoe.title + " Releases on " + selectedShoe.event_date + " for $" + selectedShoe.price + strMsg + " via KicksOnFire.com";
                shareOnFB.LinkUri = new Uri(selectedShoe.master_image, UriKind.Absolute);
                shareOnFB.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Twitter Share Status
        private void imgTwiter_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareLinkTask shareOnTW = new ShareLinkTask();
                shareOnTW.Title = selectedShoe.title;
                string strMsg = !String.IsNullOrWhiteSpace(selectedShoe.kof_link) ? ("-" + Environment.NewLine + selectedShoe.kof_link) : string.Empty;
                shareOnTW.Message = selectedShoe.title + " Releases on " + selectedShoe.event_date + " for $" + selectedShoe.price + strMsg + " via @KicksOnFire";
                shareOnTW.LinkUri = new Uri(selectedShoe.master_image, UriKind.Absolute);
                shareOnTW.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Email
        private void imgMail_MouseEnter(object sender, MouseEventArgs e)
        {//create a new MailMessage object

            try
            {
                string strimg = "";
                string kof_links = "";
                shoeid = this.NavigationContext.QueryString["id"];

                KOF.Helpers.ReleaseResult rslt = (from itm in (App.Current as App).lstReleaseResult
                                                  where itm.id == shoeid
                                                  select itm).FirstOrDefault();
                if (rslt != null)
                {
                    selectedShoe = rslt;

                    kof_links = imgKicksOnFire.Tag.ToString();
                    if (rslt.iphone_images.Count > 0)
                    {
                        strimg = rslt.iphone_images[0].ToString();
                    }
                }


                EmailComposeTask emailTask = new EmailComposeTask();
                emailTask.Subject = selectedShoe.title;
                var bi = new BitmapImage(new Uri(strimg));

                string strMsg = bi.UriSource.ToString();
                emailTask.Body = selectedShoe.title + " Releases on " + selectedShoe.event_date + " for $" + selectedShoe.price + " - " + kof_links + "\n" + strMsg + " via KicksOnFire.com";
                emailTask.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Message
        private void imgChat_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                SmsComposeTask smsTask = new SmsComposeTask();
                string strMsg = !String.IsNullOrWhiteSpace(selectedShoe.kof_link) ? ("-" + Environment.NewLine + selectedShoe.kof_link) : string.Empty;
                smsTask.Body = selectedShoe.title + " Releases on " + selectedShoe.event_date + " for $" + selectedShoe.price + strMsg + " via KicksOnFire.com";
                smsTask.Show();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Share Instagram
        private void imgInstagram_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareLinkTask shareOnIG = new ShareLinkTask();
                shareOnIG.Title = selectedShoe.title;
                string strMsg = !String.IsNullOrWhiteSpace(selectedShoe.kof_link) ? ("-" + Environment.NewLine + selectedShoe.kof_link) : string.Empty;
                shareOnIG.Message = selectedShoe.title + " Releases on " + selectedShoe.event_date + " for $" + selectedShoe.price + strMsg + " via KicksOnFire.com";
                shareOnIG.LinkUri = new Uri(selectedShoe.master_image, UriKind.Absolute);
                shareOnIG.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect to Event page
        private void imgEventDate_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {

                var splits = txtEventDate.Text.Split('/');

                var secondLast = splits[splits.Length - 2];
                var last = splits[splits.Length - 1];
                var first = splits[splits.Length - 3];
                string dates = secondLast + "/" + first + "/" + last;
                NavigationService.Navigate(new Uri("/Views/Events.xaml?title=" + txtTitle.Text + "&StartDate=" + dates + "&Description=" + txtDescription.Text, UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }


        // When Image Loaded Loader image will be  Invisible
        private void imgMain_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {

                imgLoading.Visibility = System.Windows.Visibility.Collapsed;


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect to News Tab
        private void btnNews_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/News.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect to Favorite Tab
        private void btnFavorites_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/Favorites.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect to Settings Tab
        private void btnSettings_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/Settings.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect to Release Tab
        private void btnReleases_Click(object sender, EventArgs e)
        {
            try
            {

                IsolatedStorageSettings.ApplicationSettings["loader"] = false;

                this.NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }


        // When Screen Navigated it will set textbox values
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {

            try
            {

                if (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back) return;
                if (this.NavigationContext.QueryString.ContainsKey("id"))
                {
                    shoeid = this.NavigationContext.QueryString["id"];

                    KOF.Helpers.ReleaseResult rslt = (from itm in (App.Current as App).lstReleaseResult
                                                      where itm.id == shoeid
                                                      select itm).FirstOrDefault();
                    if (rslt != null)
                    {
                        // calling analytics
                        GoogleAnalytics.EasyTracker.GetTracker().SendView("Details: " + rslt.title);

                        selectedShoe = rslt;
                        txtTitle.Text = rslt.title;
                        txtColorway.Text = rslt.style;
                        txtDescription.Text = rslt.description;
                        txtEventDate.Text = rslt.event_date;
                        txtPrice.Text = "$" + rslt.price;
                        imgKicksOnFire.Tag = rslt.kof_link;


                        if (rslt.iphone_images.Count > 0)
                        {
                            imgLoading.Visibility = System.Windows.Visibility.Visible;
                            imgMain.Source = new BitmapImage(new Uri(rslt.iphone_images[0].ToString(), UriKind.Absolute));
                            intSelectedImage = 0;
                            ListItemSource.Add(rslt.iphone_images[0].ToString());
                            item0.Visibility = System.Windows.Visibility.Visible;
                            e0.Fill = new SolidColorBrush(Colors.Red);

                            System.Globalization.Calendar cl;
                        }
                        SetFavorite();
                    }

                    for (int i = 0; i < (App.Current as App).lstImages.Count; i++)
                    {
                        switch (i)
                        {
                            case 0:
                                {
                                    item0.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 1:
                                {
                                    item1.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 2:
                                {
                                    item2.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 3:
                                {
                                    item3.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 4:
                                {
                                    item4.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 5:
                                {
                                    item5.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 6:
                                {
                                    item6.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 7:
                                {
                                    item7.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 8:
                                {
                                    item8.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                            case 9:
                                {
                                    item9.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }



                            case 10:
                                {
                                    item10.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }

                            case 11:
                                {
                                    item11.Visibility = System.Windows.Visibility.Visible;
                                    break;
                                }
                        }
                    }


                }
                else
                {
                    // I use this condition to handle creating new items.
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            base.OnNavigatedTo(e);
        }

        // Check Direction of Slider and will set image
        private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
        {
            try
            {
                if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
                {
                    if (e.HorizontalVelocity < 0)
                    {
                        intSelectedImage = ++intSelectedImage;
                        if (intSelectedImage >= selectedShoe.iphone_images.Count)
                        {
                            intSelectedImage = selectedShoe.iphone_images.Count - 1;
                            return;
                        }
                        //MessageBox.Show("Right");
                    }
                    else
                    {
                        intSelectedImage = --intSelectedImage;
                        if (intSelectedImage < 0)
                        {
                            intSelectedImage = 0;
                            return;
                        }
                        //MessageBox.Show("Left");
                    }


                    imgLoading.Visibility = System.Windows.Visibility.Visible;
                    imgMain.Source = new BitmapImage(new Uri(selectedShoe.iphone_images[intSelectedImage].ToString(), UriKind.Absolute));
                    updateUI();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }



        // Update UI
        public void updateUI()
        {
            try
            {
                //switch (lstShoeImages.SelectedIndex)
                switch (intSelectedImage)
                {
                    case 0:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 1:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e1.Fill = new SolidColorBrush(Colors.Red);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 2:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 3:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 4:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 5:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 6:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 7:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 8:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                    case 9:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Red);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }




                    case 10:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Transparent);
                            e10.Fill = new SolidColorBrush(Colors.Red);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }

                    case 11:
                        {
                            e11.Fill = new SolidColorBrush(Colors.Red);
                            e10.Fill = new SolidColorBrush(Colors.Transparent);
                            e9.Fill = new SolidColorBrush(Colors.Transparent);
                            e1.Fill = new SolidColorBrush(Colors.Transparent);
                            e2.Fill = new SolidColorBrush(Colors.Transparent);
                            e3.Fill = new SolidColorBrush(Colors.Transparent);
                            e4.Fill = new SolidColorBrush(Colors.Transparent);
                            e5.Fill = new SolidColorBrush(Colors.Transparent);
                            e6.Fill = new SolidColorBrush(Colors.Transparent);
                            e7.Fill = new SolidColorBrush(Colors.Transparent);
                            e8.Fill = new SolidColorBrush(Colors.Transparent);
                            e0.Fill = new SolidColorBrush(Colors.Transparent);
                            break;
                        }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }



        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {

            base.OnNavigatedFrom(e);

        }

        private void imgMain_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            intSelectedImage = ++intSelectedImage;
            if (intSelectedImage >= selectedShoe.iphone_images.Count)
            {
                intSelectedImage = 0;

            }


            imgLoading.Visibility = System.Windows.Visibility.Visible;
            imgMain.Source = new BitmapImage(new Uri(selectedShoe.iphone_images[intSelectedImage].ToString(), UriKind.Absolute));
            updateUI();
        }



    }
}